//
//  ShowImageViewController.m
//  photographDemo
//
//  Created by 李胜军 on 2017/10/20.
//  Copyright © 2017年 李胜军. All rights reserved.
//

#import "ShowImageViewController.h"
//#import "WYCBindingIDController.h"
//#import "WYCBindingIDSideController.h"
//#import "WYCBankCardController.h"
//#import "WYCIDHoldController.h"
//#import "WYCDebitCardController.h"
//#import "WYCCityController.h"
//#import "WYCAuthenticationController.h"
//#import "WYCDebitCardController.h"

#define kScreenBounds   [UIScreen mainScreen].bounds
#define kScreenWidth  kScreenBounds.size.width*1.0
#define kScreenHeight kScreenBounds.size.height*1.0

@interface ShowImageViewController ()
{
    UIImageView * imageV ;
}

@end

@implementation ShowImageViewController

-(void)setimageStr:(UIImage *)imageStr{
    
    _imageStr = imageStr;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    imageV = [[UIImageView alloc]initWithFrame:self.view.bounds];
    imageV.image = _imageStr;
    imageV.contentMode = UIViewContentModeScaleAspectFit;
    [self.view addSubview:imageV];
    
    
    UIButton * done = [[UIButton alloc]initWithFrame:CGRectMake(50, kScreenHeight-100, 100, 40)];
    [done addTarget:self action:@selector(doneClick) forControlEvents:UIControlEventTouchUpInside];
    [done setTitle:@"确定" forState:UIControlStateNormal];
    [done setBackgroundColor:[UIColor orangeColor]];
    [self.view addSubview:done];
    
    
    UIButton *cancelBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    cancelBtn.frame = CGRectMake(kScreenWidth-140, kScreenHeight-100, 100, 40);
    [cancelBtn setTitle:@"取消" forState:UIControlStateNormal];
    cancelBtn.titleLabel.textAlignment = NSTextAlignmentCenter;
    [cancelBtn setBackgroundColor:[UIColor orangeColor]];
    [cancelBtn addTarget:self action:@selector(cancle) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:cancelBtn];
    
}


-(void)doneClick{
    
    
//    if ([self.strtype isEqualToString:@"1"]) {
//        WYCLog(@"========身份证正面=========");
//        
        //图片压缩
        NSData * data = UIImageJPEGRepresentation(_imageStr, 1);
        NSString *encodedImageStr = [data base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength];

        NSMutableDictionary * params = [NSMutableDictionary dictionary];
        params[@"base64Img"] = encodedImageStr;
        params[@"side"] = @"1";
        [HttpTool POST:ocridcard params:params success:^(NSURLSessionDataTask *task, id responseObject) {
            WYCLog(@"============%@",responseObject);
//
//                if ([[responseObject objectForKey:@"code"] intValue] == 0) {
//                    WYCBindingIDController * binding = [[WYCBindingIDController alloc] init];
//                    NSDictionary * dict = [responseObject objectForKey:@"result"];
//                    //地址
//                    binding.address = [dict objectForKey:@"address"];
//            
//            
//                    //出生年月日
//                    binding.birth = [dict objectForKey:@"birth"];
//            
//            
//                    //图片
//                    binding.faceUrl = [dict objectForKey:@"faceUrl"];
//            
//            
//                    //名字
//                    binding.name = [dict objectForKey:@"name"];
//            
//                    //身份证号
//                    binding.num = [dict objectForKey:@"num"];
//            
//                    //民族
//                    binding.nationality = [dict objectForKey:@"nationality"];
//            
//            
//                    //性别
//                    binding.sex = [dict objectForKey:@"sex"];
//                      [self presentViewController:binding animated:NO completion:nil];
//                    }else{
//            
//                        [SVProgressHUD showImage:[UIImage imageNamed:@""] status:msgStr];
//                    }
        } fail:^(NSURLSessionDataTask *task, NSError *error) {
            [SVProgressHUD showImage:[UIImage imageNamed:@""] status:Failed];
        }];
//
//    }
//    //身份证反面
//    else if ([self.strtype isEqualToString:@"2"]) {
//        NSData * data = UIImageJPEGRepresentation(_imageStr, 1);
//        NSString *encodedImageStr = [data base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength];
//        
//        NSMutableDictionary * params = [NSMutableDictionary dictionary];
//        params[@"base64Img"] = encodedImageStr;
//        params[@"side"] = @"2";
//        [HttpTool POST:ocridcard params:params success:^(NSURLSessionDataTask *task, id responseObject) {
//            if ([[responseObject objectForKey:@"code"] intValue] == 0) {
//                
//            WYCBindingIDSideController * side = [[WYCBindingIDSideController alloc] init];
//            NSDictionary * dict = [responseObject objectForKey:@"result"];
//            side.startimestr = [dict objectForKey:@"startDate"];
//            side.endtimestr = [dict objectForKey:@"endDate"];
//            side.faceUrl = [dict objectForKey:@"backUrl"];
//            side.signingstr = [dict objectForKey:@"issue"];
//                
//            [self presentViewController:side animated:NO completion:nil];
//                
//            }else{
//                
//             [SVProgressHUD showImage:[UIImage imageNamed:@""] status:msgStr];
//             }
//        } fail:^(NSURLSessionDataTask *task, NSError *error) {
//            [SVProgressHUD showImage:[UIImage imageNamed:@""] status:Failed];
//        }];
//
//    }
//    //银行卡
//    else if ([self.strtype isEqualToString:@"3"]) {
//        NSMutableDictionary * params = [NSMutableDictionary dictionary];
//
//        NSData * data = UIImageJPEGRepresentation(_imageStr, 1);
//        NSString *encodedImageStr = [data base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength];
//        params[@"userId"] = [WYCAccountTool unarchiveuserId];
//        params[@"ticket"] = [WYCAccountTool unarchiveticket];
//        params[@"base64Img"] = encodedImageStr;
//        [HttpTool POST:ocrbankcard params:params success:^(NSURLSessionDataTask *task, id responseObject) {
//            WYCLog(@"---------%@",responseObject);
//            if ([[responseObject objectForKey:@"code"] intValue] == 0) {
//                NSDictionary * dict = responseObject[@"result"];
//                
//            WYCBankCardController * idhold = [[WYCBankCardController alloc] init];
//                idhold.cardNumber = [dict objectForKey:@"cardNumber"];
//                idhold.bankCardUrl = [dict objectForKey:@"bankCardUrl"];
//                idhold.bankName = [dict objectForKey:@"bankName"];
//                idhold.bankId = [dict objectForKey:@"bankId"];
//            [self presentViewController:idhold animated:NO completion:nil];
//                
//            }else{
//                
//            [SVProgressHUD showImage:[UIImage imageNamed:@""] status:msgStr];
//    
//            }
//        
//        } fail:^(NSURLSessionDataTask *task, NSError *error) {
//            [SVProgressHUD showImage:[UIImage imageNamed:@""] status:Failed];
//        }];
//
//    }
//    
//    //手持身份证
//    else if ([self.strtype isEqualToString:@"4"]) {
//        
//        NSMutableDictionary * params = [NSMutableDictionary dictionary];
//        
//        NSData * data = UIImageJPEGRepresentation(_imageStr, 1);
//        NSString *encodedImageStr = [data base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength];
//        params[@"userId"] = [WYCAccountTool unarchiveuserId];
//        params[@"ticket"] = [WYCAccountTool unarchiveticket];
//        params[@"base64Img"] = encodedImageStr;
//        [HttpTool POST:uploadimage params:params success:^(NSURLSessionDataTask *task, id responseObject) {
//            WYCLog(@"responseObject%@",responseObject);
//            if ([[responseObject objectForKey:@"code"] intValue] == 0) {
//                [SVProgressHUD showImage:[UIImage imageNamed:@""] status:@"成功"];
//                [[NSNotificationCenter defaultCenter] postNotificationName:@"holdID" object:nil];
//                
//                UIViewController *vc =self.presentingViewController;
//                
//                //ReadBookController要跳转的界面
//                
//                while (![vc isKindOfClass:[WYCAuthenticationController class]]) {
//                    
//                    
//                    
//                    vc = vc.presentingViewController;
//                    
//                }
//                
//                
//                
//                [vc dismissViewControllerAnimated:YES completion:nil];
//            }else{
//                
//                [SVProgressHUD showImage:[UIImage imageNamed:@""] status:msgStr];
//            }
//        } fail:^(NSURLSessionDataTask *task, NSError *error) {
//            
//        }];
//    
//    }
//    
//    //手持银行卡
//    else if ([self.strtype isEqualToString:@"5"]){
//        
//        
//        NSMutableDictionary * params = [NSMutableDictionary dictionary];
//        
//        NSData * data = UIImageJPEGRepresentation(_imageStr, 1);
//        NSString *encodedImageStr = [data base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength];
//        params[@"userId"] = [WYCAccountTool unarchiveuserId];
//        params[@"ticket"] = [WYCAccountTool unarchiveticket];
//        params[@"base64Img"] = encodedImageStr;
//        [HttpTool POST:uploadimage params:params success:^(NSURLSessionDataTask *task, id responseObject) {
//            WYCLog(@"responseObject%@",responseObject);
//            if ([[responseObject objectForKey:@"code"] intValue] == 0) {
//                [SVProgressHUD showImage:[UIImage imageNamed:@""] status:@"成功"];
//                [[NSNotificationCenter defaultCenter] postNotificationName:@"holdcard" object:nil];
//                
//                UIViewController *vc =self.presentingViewController;
//                
//                //ReadBookController要跳转的界面
//                
//                while (![vc isKindOfClass:[WYCAuthenticationController class]]) {
//                    
//                    
//                    
//                    vc = vc.presentingViewController;
//                    
//                }
//                
//                
//                
//                [vc dismissViewControllerAnimated:YES completion:nil];
//            }else{
//                
//                [SVProgressHUD showImage:[UIImage imageNamed:@""] status:msgStr];
//            }
//        } fail:^(NSURLSessionDataTask *task, NSError *error) {
//            
//        }];
    
//}
}

-(void)cancle{
    
    
    [self dismissViewControllerAnimated:YES completion:nil];
    
}





@end
